<template>
  <div class="create-modal">
    <div class="create-modal-inner">
      <div class="header">
        <div
          class="close"
          @click="$emit('close')"
        ><i class="el-icon-close"></i></div>
      </div>
      <div class="content">
        <el-form
          ref="myForm"
          :model="form"
          label-position="top"
          size="mini"
          :rules="rules"
        >
          <el-row :gutter="20">
            <el-col :span="24">
              <el-form-item label="请选择">
                <el-select
                  v-model="form.csName"
                  placeholder=""
                  style="width: 100%;"
                >
                  <el-option value="长沙超算中心">长沙超算中心</el-option>
                  <el-option value="深圳超算中心">深圳超算中心</el-option>
                  <el-option value="天津超算中心">长沙超算中心</el-option>
                  <el-option value="上海超算中心">上海超算中心</el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col span="12">
              <el-form-item
                label="您的姓名"
                prop="username"
              >
                <el-input
                  placeholder="请输入您的姓名"
                  v-model="form.username"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col span="12">
              <el-form-item
                label="您的电话"
                prop="phone"
              >
                <el-input
                  placeholder="请输入您的电话"
                  v-model.number="form.phone"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col span="12">
              <el-form-item
                label="您的邮箱"
                prop="email"
              >
                <el-input
                  placeholder="请输入您的邮箱"
                  v-model="form.email"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col span="12">
              <el-form-item
                label="您的单位/学校"
                prop="company"
              >
                <el-input
                  placeholder="请输入您的单位/学校"
                  v-model="form.company"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col span="24">
              <el-form-item label="备注">
                <el-input
                  type="textarea"
                  placeholder="请输入"
                  v-model="form.rearmk"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>

      </div>
      <div class="footer">
        <el-button
          type="primary"
          size="small"
          style="width:100px;"
          @click="onSubmit"
        >提交</el-button>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        form: {
          csName: '长沙超算中心'
        },
        rules: {
          username: [{ required: true, message: '请输入' }],
          phone: [{ required: true, message: '请输入' }, { pattern: /^\d{11}$/g, message: '请输入正确的手机号码' }],
          email: [{ required: true, message: '请输入' }, { type: 'email', message: '请输入有效的Email' }],
          company: [{ required: true, message: '请输入' }]
        }
      }
    },
    methods: {
      onSubmit () {
        this.$refs.myForm.validate(valid => {
          if (valid) {
            this.$message.success('恭喜您，您已提交成功，稍后会有工作人员联系您！')
            this.$emit('close')
          }
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
.create-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.25);
  overflow: hidden;
  z-index: 9999;
}
.create-modal-inner {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 660px;
  background: #eeeeee;
  border-radius: 8px;
  box-shadow: 0px 2px 2px 0px rgba(0, 0, 0, 0.25);
  // filter: blur(25px);

  .content {
    padding: 30px;
    padding-bottom: 8px;
  }

  .header {
    width: 600px;
    height: 160px;
    background: url(./images/create.png) no-repeat;
    border-radius: 8px 8px 0px 0px;
    position: relative;
    .close {
      position: absolute;
      top: 20px;
      right: 20px;
      color: #ffffff !important;
      font-size: 20px;
      z-index: 10;
      opacity: 1;
    }
  }

  .footer {
    margin: 0 30px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding: 20px 0;
    text-align: center;
  }
}

/deep/ .el-form--label-top .el-form-item__label {
  padding-bottom: 0 !important;
}
</style>
